<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="query.keyValue" placeholder="关键字"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getPermission">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="pageInfo.permission" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
			<el-table-column type="selection" width="55">
			</el-table-column>
			<el-table-column type="index" width="60">
			</el-table-column>
			<el-table-column prop="name" label="权限名称" width="150" sortable>
			</el-table-column>
			<el-table-column prop="url" label="url" width="220"  sortable>
			</el-table-column>
			<el-table-column prop="descs" label="描述" width="220" sortable>
			</el-table-column>
			<el-table-column prop="sn" label="绝对路径" width="220" sortable>
			</el-table-column>
			<el-table-column prop="permission.name" label="父权限" min-width="100" sortable>
			</el-table-column>
		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination layout="prev, pager, next" @current-change="handleCurrentChange"
						   :current-page="query.currentPage" :page-size="query.pageSize" :total="pageInfo.total" style="float:right;">
			</el-pagination>
		</el-col>

	</section>
</template>

<script>
	// import util from '../../common/js/util'
	// //import NProgress from 'nprogress'
	// import { getUserListPage, removeUser, batchRemoveUser, editUser, addUser } from '../../api/api';

	export default {
		data() {
			return {
				filters: {
					name: ''
				},
				pageInfo:{
					total:0,
					permission:[]
				},
				query:{
					currentPage:1,
					pageSize:10,
					keyValue:''
				},
				users: [],
				total: 0,
				page: 1,
				listLoading: false,
				sels: [],//列表选中列

				editFormVisible: false,//编辑界面是否显示
				editLoading: false,
				editFormRules: {
					name: [
						{ required: true, message: '请输入姓名', trigger: 'blur' }
					]
				},
				addFormVisible: false,//新增界面是否显示
				addLoading: false,
				addFormRules: {
					name: [
						{ required: true, message: '请输入姓名', trigger: 'blur' }
					]
				},
				//新增界面数据
				addForm: {
					name: '',
					sex: -1,
					age: 0,
					birth: '',
					addr: ''
				}

			}
		},
		methods: {
			handleCurrentChange(val) {
				this.query.currentPage = val;
				this.getPermission();
			},
			//获取用户列表
			getPermission() {
				this.$http.post("/permission",this.query).then(result=>{
					result=result.data;
					if (result.success){
						this.pageInfo.total=result.object.size;
						this.pageInfo.permission=result.object.rows;
					}else {
						this.$message({
							message: result.message,
							type: 'error'
						});
					}

				}).catch(()=>{

				})
			},

			selsChange: function (sels) {
				this.sels = sels;
			},
		},
		mounted() {
			this.getPermission();
		}
	}

</script>

<style scoped>

</style>